package com.spring_mvc_hibernate_aop.aspect;


import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class MyLoggingAspect {
    @Around("execution(* com.spring_mvc_hibernate_aop.dao.*.*(..))")
    public Object AroundAllRepositoryMethodAdvice(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        MethodSignature methodSignature=(MethodSignature) proceedingJoinPoint.getSignature();
        String methodName=methodSignature.getName();
        System.out.println("Begin of "+methodName);
        Object targetMethod=proceedingJoinPoint.proceed();
        System.out.println("End of "+methodName);
        return targetMethod;
    }
}
